package cn.tedu.online.day05;

import java.util.Arrays;

public class BubbleSort {
    public static void main(String[] args) {
        int[] ary = {23, 12, 5, 56, 0, 8, 15};
        //使用冒泡排序对数组进行升序排序
        for (int i = 0; i < ary.length - 1; i++) {
            for (int j = 0; j < ary.length - 1 - i; j++) {
                if (ary[j] < ary[j + 1]) {
                    int tmp = ary[j];
                    ary[j] = ary[j + 1];
                    ary[j + 1] = tmp;
                }
            }
        }
          //  System.out.println(Arrays.toString(ary));

    aa();
    }
    public static void aa() {
        String[] ary = {"666", "wwww", "wewewdw", "sdsdas"};
        for (int i = 0; i < ary.length - 1; i++) {
            for (int j = 0; j < ary.length - 1 - i; j++) {
                if (ary[j].compareTo(ary[j + 1]) > 0) {
                    String tmp = ary[j];
                    ary[j] = ary[j + 1];
                    ary[j + 1] = tmp;
                }
            }
        }
        System.out.println(Arrays.toString(ary));
    }
}
